﻿#region << 文件说明 >>

/*----------------------------------------------------------------
 * 命名空间：Vampirewal.BlogCore.Controls
 * 唯一标识：35f060db-528a-468c-8054-da3b04bc64d7
 * 文件名：TagControl
 *
 * 创建者：杨程
 * 电子邮箱：235160615@qq.com
 * 创建时间：2024/6/14 17:47:35
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

#endregion << 文件说明 >>

namespace Vampirewal.BlogCore;

/// <summary>
/// 标签控件
/// </summary>
public sealed class Tag : ControlBase
{
    internal Tag()
    {

    }

    /// <summary>
    /// 标签类型
    /// </summary>
    public TagType Type { get; set; }


    public override string Id { get; set; }
    public override string Title { get; set; }

    public override string ConverToHtml()
    {
        return $"<el-tag type=\"{Type.GetDescription()}\" style=\"left:5px;\">{Title}</el-tag>";
    }
}

/// <summary>
/// 标签类型枚举
/// </summary>
public enum TagType
{
    /// <summary>
    ///
    /// </summary>
    [Description("primary")]
    Primary,

    /// <summary>
    ///
    /// </summary>
    [Description("success")]
    Success,

    /// <summary>
    ///
    /// </summary>
    [Description("info")]
    Info,

    /// <summary>
    ///
    /// </summary>
    [Description("warning")]
    Warning,

    /// <summary>
    ///
    /// </summary>
    [Description("danger")]
    Danger
}

public static partial class App
{
    /// <summary>
    /// 创建Tag
    /// </summary>
    /// <param name="content">标签内容</param>
    /// <param name="type">类型</param>
    /// <returns></returns>
    public static Tag CreateTag(string content, TagType type)
    {
        Tag tag = new Tag()
        {
            Id = GenerateId(),
            Title = content,
            Type = type
        };

        return tag;
    }

    
}